package com.hejing.异常处理方式2_throws抛出异常;

import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * ClassName: OverrideTest
 * Package: com.hejing.异常处理方式2_throws抛出异常
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-04-11 10:16
 * @Version: 1.0
 */
public class OverrideTest {

    public static void main(String[] args) {
        Father f1 = new Son();
        try {
            f1.method01();
        } catch (IOException e) {  // 编译看左边，所以需要写父类被重写方法报出的异常类型
            e.printStackTrace();
        }
    }
}

class Father{

    public void method01() throws IOException {
        System.out.println("Father: method01执行");
    }
}

class Son extends Father{

    @Override
    public void method01() throws FileNotFoundException {
        System.out.println("Son: method01执行");
    }
}
















































